'use strict'

const Mock = require('mockjs')

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app
  router.get('/', controller.home.index)

  // 获取todos列表路由
  router.get('/api/list.json', async ctx => {
    // 生成mock数据
    const obj = Mock.mock({
      'data|5-10': [{ id: '@increment()', info: '@sentence(5,10)', done: false }]
    })
    // 响应数据
    ctx.body = obj.data
  })
}
